package com.dingpeikeji.quickdeer.modules.officeup.service;

import java.util.Date;
import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.dingpeikeji.quickdeer.core.common.persistence.Page;
import com.dingpeikeji.quickdeer.core.common.service.CrudService;
import com.dingpeikeji.quickdeer.core.modules.sys.entity.User;
import com.dingpeikeji.quickdeer.modules.officeup.dao.TOfficeUpDao;
import com.dingpeikeji.quickdeer.modules.officeup.entity.TOfficeUp;

/**
 * 普通客户升级Service
 * @author dingpei
 * @version 2016-12-08
 */
@Service
@Transactional(readOnly = true)
public class TOfficeUpService extends CrudService<TOfficeUpDao, TOfficeUp> {

	public TOfficeUp get(String upid) {
		return super.get(upid);
	}
	
	public List<TOfficeUp> findList(TOfficeUp tOfficeUp) {
		return super.findList(tOfficeUp);
	}
	
	public Page<TOfficeUp> findPage(Page<TOfficeUp> page, TOfficeUp tOfficeUp) {
		return super.findPage(page, tOfficeUp);
	}
	
	@Transactional(readOnly = false)
	public void save(TOfficeUp tOfficeUp) {
		Date date = new Date();
		tOfficeUp.setUpdateDate(date);
		if(tOfficeUp.getUpid() == null){
			User user = tOfficeUp.getUpdateBy();
			tOfficeUp.setCreateBy(user);
			tOfficeUp.setCreateDate(date);
			tOfficeUp.setOffice(user.getOffice());
			dao.insert(tOfficeUp);
		} else {
			dao.update(tOfficeUp);
		}
	}
	
	@Transactional(readOnly = false)
	public void delete(TOfficeUp tOfficeUp) {
		super.delete(tOfficeUp);
	}
	
}